package com.ctrl.riveradministrator.mvp.view.activity.trace.daemon;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

/**
 * 保活处理服务
 */
@Deprecated
public class DaemonService extends Service implements DaemonReceiver.ScreenStateListener {

    private DaemonReceiver daemonReceiver;

    public DaemonService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        daemonReceiver = new DaemonReceiver(this);
        daemonReceiver.begin(this);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public IBinder onBind(Intent intent) {

        return null;
    }

    @Override
    public void onScreenOn() {
        // 亮屏，finish一个像素的Activity
        DaemonManager.getInstance(DaemonService.this)
                .finishKeepLiveActivity();
    }

    @Override
    public void onScreenOff() {
        // 灭屏，启动一个像素的Activity
        DaemonManager.getInstance(DaemonService.this)
                .startKeepLiveActivity();
    }
}
